import { getUserInfoServer } from "@/servers/app-servers"
import { userInfoAtom } from "@/store/user"
import Storage from "@/utils/Storage"
import { useAtom } from "jotai"

export const useUpdateUserInfo = () => {
    const [userInfo , setUserInfo] = useAtom(userInfoAtom)
    const updateUserInfo = async () => {
        const res = await getUserInfoServer(userInfo.user_id)
        setUserInfo(res.data)
        await Storage.setStorage("userInfo", JSON.stringify(res.data))
    }
    return {
        updateUserInfo
    }
}